#include "MyVector.h"

/* 当前编译器不支持 export 关键字
 * 报错信息如下：
 * warning: keyword ‘export’ not implemented, and will be ignored
 * 6 | export template<typename T>
 * main.cpp:(.text+0x29): undefined reference to `MyVector<int>::MyVector(int)'
 */
export template<typename T>
MyVector<T>::MyVector(int size) : length(size)
{
    data = new T(size);
}

export template<typename T>
MyVector<T>::~MyVector()
{
    if(data != nullptr) {
        delete [] data;
        data = nullptr;
    }
}

export template<typename T>
T& MyVector<T>::at(int index) const
{
    assert(index < length);
    return data[index];
}